﻿namespace Digitalmes.Domain.ValueObjects;

/// <summary>
/// 图数据结构。
/// </summary>
public sealed class GraphVo : ValueObject
{
    /// <summary>
    /// 节点集合。
    /// </summary>
    [NotNull]
    public List<GraphNodeVo>? Nodes { get; set; }

    /// <summary>
    /// 边集合。
    /// </summary>
    [NotNull]
    public List<GraphEdgeVo>? Edges { get; set; }

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return new object[]
        {
            Nodes, Edges
        };
    }
}

/// <summary>
/// 图节点
/// </summary>
public sealed class GraphNodeVo : ValueObject
{
    [NotNull]
    public string? Id { get; set; }

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return new object[]
        {
            Id
        };
    }
}

/// <summary>
/// 图边
/// </summary>
public sealed class GraphEdgeVo : ValueObject
{
    [NotNull]
    public string? Id { get; set; }

    [NotNull]
    public string? SourceNodeId { get; set; }

    [NotNull]
    public string? TargetNodeId { get; set; }

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return new object[]
        {
            Id,
            SourceNodeId,
            TargetNodeId,
        };
    }
}
